package ch01;

public class MoneyTest {
    public static void main(String[] args) {
        // 10元分成三个红包
        double money=10;
        // 生成随机数
        double r1=Math.random()*money;
        double r2=Math.random()* (money-r1) ;
        double r3=money - r1 - r2;

        // 保留两位小数
        //3.4875890980217186--348.75--348--3.48
        r1=(int)(r1*100)/100.0;
        r2=(int)(r2*100)/100.0;

        r3=money-r1-r2;
        r3=(int)(r3*100+0.5)/100.0; //0.35999999999999976

        //0.35499999999999976  35.49999 35.499999  35   0.35

        System.out.println(r1);
        System.out.println(r2);
        System.out.println(r3);
    }
}
